package AppConfig

import (
	"fmt"
	"github.com/spf13/viper"
	"log"
)

type AppConfig struct {
	MysqlConfig
	RedisConfig
}

type MysqlConfig struct {
	User     string
	Pwd      string
	Host     string
	Port     int
	Database string
}
type RedisConfig struct {
	Addr     string
	Password string
	Db       int
}

var AppConf AppConfig

func InitApp() {
	viper.SetConfigFile("../AppConfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic("数据库配置文件读取失败")
		return
	}
	viper.Unmarshal(&AppConf)
	log.Println("数据库配置文件读取成功", AppConf)
	fmt.Println("数据库配置文件读取成功")
}
